/*
 * @Description: Description
 * @Autor: Chen
 * @Date: 2020-05-12 17:26:58
 * @LastEditors: chen
 * @LastEditTime: 2021-03-12 10:10:13
 */
import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { AnyJson } from './data-types/common.type';
import { Observable, map } from 'rxjs';
import { ServicesModule } from './services.module';

@Injectable({
  providedIn: ServicesModule,
})
export class ImagesService {
  constructor(private http: HttpClient) {}

  getImagesList(params: AnyJson, body: AnyJson): Observable<AnyJson> {
    return this.http
      .post('/img/imageMsgSearch', body, { params })
      .pipe(map((res) => res as AnyJson));
  }

  getImage(params: AnyJson): Observable<AnyJson> {
    return this.http
      .get('/img/imageMsgSearchOne', { params })
      .pipe(map((res) => res as AnyJson));
  }

  addImage(params: AnyJson): Observable<AnyJson> {
    return this.http
      .post('/img/imageMsgInsert', params)
      .pipe(map((res) => res as AnyJson));
  }

  updateImage(params: AnyJson): Observable<AnyJson> {
    return this.http
      .post('/img/imageMsgUpdate', params)
      .pipe(map((res) => res as AnyJson));
  }

  delImage(params: AnyJson): Observable<AnyJson> {
    return this.http
      .get('/img/imageMsgDel', { params })
      .pipe(map((res) => res as AnyJson));
  }
  clearSort(params: AnyJson): Observable<AnyJson> {
    return this.http
      .get('/img/imageSortClear', { params })
      .pipe(map((res) => res as AnyJson));
  }
}
